<template>
  <div class="mod-config">
    <basic-container>
      <navigationHeTong :sign="{a:false,b:false,c:false,d:false,e:true,f:false}"></navigationHeTong>
      <!-- 填报审核-->
      <HeTongZhiBiaoTianBaoShenHeTable v-if="zhiShow=='1'" ref="hetongzhibiaotianbaoshenhetable" :hetongzhibiaoTable='hetongzhibiaoTable' :hetongIds="hetongIds"  v-on:fnBackOldPage='fnBackOldPage'></HeTongZhiBiaoTianBaoShenHeTable>
      <!--      填报汇总-->
      <TianBaoTable v-if="zhiShow=='2'" ref="tianbaotable" :tianBaoTable="tianBaoTable" @fnBackOldPage="fnBackOldPage"></TianBaoTable>
      <!--合同创建-->
      <hetongcjTable v-if="zhiShow=='3'" class="boxsty zhiBiao" @hetongcjC="hetongcjC" :hetongzhibiaoTable="hetongzhibiaoTable" ></hetongcjTable>
    </basic-container>
  </div>
</template>

<script>
import {fetchList, delObj} from '@/api/hetongrenwu/hetonghtxxdjb'
import HeTongZhiBiaoTable from '@/views/hetongrenwu/components/hetongzhibiao-table.vue'
import HeTongZhiBiaoTianBaoShenHeTable from '@/views/hetongrenwu/components/hetongzhibiaotianbaoshenhe-table.vue'
import TianBaoTable from '@/views/hetongrenwu/components/tianbao-table.vue'
import {mapGetters} from 'vuex'
import hetongcjTable from "@/views/hetongrenwu/components/hetongtbsh-table"
export default {
  components: {
    HeTongZhiBiaoTable,
    TianBaoTable,
    HeTongZhiBiaoTianBaoShenHeTable,
    hetongcjTable,
  },
  data() {
    return {
      dataForm: {
        key: ''
      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      addOrUpdateVisible: false,
      radio:'1',
      radioTwo:'1',
      zhiShow:'3',
      hetongzhibiaoTable:{
        lastPage:'tbsh',
        showSearch:true,
        pageTitle:'业绩合同',
        showBackBtn:false
      },
      hetongzhibiaotianbaoshenheTable:{
        lastPage:'tbsh',
        showSearch:true,
        pageTitle:'业绩合同',
        showBackBtn:false
      },
      tianBaoTable:{

      },
      hetongIds:Number,
      taskId:0,
      zbndid:0
    }
  },
  created() {
   // this.getDataList()
    this.$nextTick(() => {
      //this.$refs.hetongzhibiaotable.init(this.hetongzhibiaoTable);
      this.$refs.hetongzhibiaotianbaoshenhetable.init(this.hetongzhibiaotianbaoshenheTable);
    });
  },
  computed: {
    ...mapGetters(['permissions'])
  },
  methods: {
    hetongcjC(hetongcjC){
      if(hetongcjC){
        this.hetongIds=hetongcjC.htId
        this.zbndid=hetongcjC.id;
        this.taskId=hetongcjC.taskId
        this.zhiShow=1
        this.hetongzhibiaoTable={
            lastPage:'tbsh',
            showSearch:true,
            pageTitle:'业绩合同',
            showBackBtn:false,
            streamId:hetongcjC.streamId,
            programInterface:hetongcjC.programInterface,
            taskId:hetongcjC.taskId,
            zbndid:hetongcjC.id,
            taskId:hetongcjC.taskId,
            rows:hetongcjC
        };

      }
    },
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true
      fetchList(Object.assign({
        current: this.pageIndex,
        size: this.pageSize,
        htId:this.hetongIds
      })).then(response => {
        this.dataList = response.data.data.records
        this.totalPage = response.data.data.total
      })
      this.dataListLoading = false
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    // 新增 / 修改
    addOrUpdateHandle(id) {
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(id)
      })
    },
    // 删除
    deleteHandle(id) {
      this.$confirm('是否确认删除ID为' + id, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function () {
        return delObj(id)
      }).then(data => {
        this.$message.closeAll();
        this.$message.success('删除成功')
        this.getDataList()
      })
    },
    //子集信息
    fnBackOldPage(data){
      if(data=='toTianBaoHuiZong'){
        this.zhiShow=2;
      }else if(data=='返回原页面'){
        this.zhiShow=1;
        this.$nextTick(() => {
          this.$refs.hetongzhibiaotable.init(this.hetongzhibiaoTable);
        });
      }else if(data=='返回合同创建'){
        this.zhiShow=3
      }
    },
  }
}
</script>
